const state = {
  key:"",
  address: "福建师范大学旗山校区",
  ad_latitude: 26.026817,
  ad_longitude:119.209317,
  nowCity:"福州",
  city_latitude:26.074209,
  city_longitude:119.296471
}

const getters = {
  getAddress(state){
    return state.address;
  },
  getAddressInfo(state){
    return {
      address: state.address,
      latitude: state.ad_latitude,
      longitude: state.ad_longitude
    }
  },
  getKey(state){
    return state.key;
  },
  getCityInfo(state){
    return {
      cityName: state.nowCity,
      latitude: state.city_latitude,
      longitude: state.city_longitude
    }
  },
  getNowCity(state){
    return state.nowCity;
  }
}
const actions = {
  setNewKey:({commit},newKey) => {
    commit('setKey',newKey);
  },

}

const mutations = {
  setNewAddress(state,address){
    state.address = address;
  },
  setKey(state,newKey){
    state.key = newKey;
  },
  setNowCity(state,{name,x,y}){
    state.nowCity = name;
    state.city_latitude = x;
    state.city_longitude = y;
  },
  setNowAddress(state,{name,x,y}){
    console.log(x,y);
    state.address = name;
    state.ad_latitude = x;
    state.ad_longitude = y;
  }
}

export default {
  state,
  getters,
  mutations,
  actions
}
